import type {
  ProjectApplicationAddDTOType,
  ProjectApplicationSearchDTOType,
  ProjectApplicationSearchVOType,
  ProjectApplicationUpdateDTOType
} from '@/resources/interface/projectApplication/ProjectApplicationTypes'
import type { TableColumn } from '@/components/CommonTable.vue'
import { ComponentEnum, type FormItemConfig } from '@/components/CommonDialogForm.vue'
import { RoleUtils } from '@/utils/RoleUtils.ts'

/**
 * 选题申请表 参数对象
 */
export class ProjectApplicationParams {
  /**
   * 表单参数
   */
  static formColumn: FormItemConfig[] = [
    {
      label: '学生姓名',
      prop: 'studentName',
      type: ComponentEnum.LABEL,
      field: 'studentName',
    },
    {
      label: '题目',
      prop: 'projectName',
      type: ComponentEnum.LABEL,
      field: 'projectName',
    },
    {
      label: '教师名称',
      prop: 'teacherName',
      type: ComponentEnum.LABEL,
      field: 'teacherName',
    },
    {
      label: '申请时间',
      prop: 'applyTime',
      type: ComponentEnum.LABEL,
      field: 'applyTime',
    },
    {
      label: '审核状态',
      prop: 'status',
      type: ComponentEnum.SELECT,
      field: 'status',
      options: [
        {
          label: '未审核',
          value: 0,
          disabled: true,
        },
        {
          label: '审核通过',
          value: 1,
        },
        {
          label: '审核不通过',
          value: 2,
        },
      ],
    },
    {
      label: '审核意见',
      prop: 'reviewComment',
      type: ComponentEnum.INPUT,
      field: 'reviewComment',
      attribute: {
        type: 'textarea',
        rows: 4,
        showWordLimit: true,
        maxlength: 400,
        showCount: true,
        placeholder: '请输入审核意见',
        clearable: true,
        autosize: {
          minRows: 4,
          maxRows: 8,
        },
        resize: 'vertical',
        style: {
          width: '100%',
        },
      },
    },
  ]

  /**
   * 表格参数
   */
  static tableColumn: TableColumn[] = [
    {
      label: '学生名',
      field: 'studentName',
    },
    {
      label: '教师名称',
      field: 'teacherName',
    },
    {
      label: '题目名称',
      field: 'projectName',
    },
    {
      label: '申请时间',
      field: 'applyTime',
    },
    {
      label: '审核状态',
      field: 'status',
      formatter(row) {
        return row.status === 0 ? '未审核' : row.status === 1 ? '审核通过' : '审核不通过'
      },
    },
    {
      label: '审核意见',
      field: 'reviewComment',
    },
    {
      label: '审核人姓名',
      field: 'reviewName',
    },
    {
      label: '审核时间',
      field: 'reviewTime',
    },
    {
      label: '操作',
      field: 'right',
      attribute: {
        fixed: 'right',
        width: '200px',
      },
      template: {
        options: [
          {
            type: 'primary',
            size: 'small',
            method: 'audit',
            label: '审核',
            show: (params:ProjectApplicationSearchVOType) => RoleUtils.verifyRole([1, 3])&&params.status==0,
          },
          {
            type: 'success',
            size: 'small',
            method: 'showDetail',
            label: '查看',
          },
        ],
      },
    },
  ]
  /**
   * 添加对象
   */
  static addDTO: ProjectApplicationAddDTOType = {
    studentId: 0,
    projectId: 0,
    applyTime: '',
    status: 0,
    reviewComment: '',
    reviewerId: 0,
    reviewTime: '',
  }
  /**
   * 修改对象
   */
  static updateDTO: ProjectApplicationUpdateDTOType = {
    id: 0,
    studentId: 0,
    projectId: 0,
    applyTime: '',
    status: 0,
    reviewComment: '',
    reviewerId: 0,
    reviewTime: '',
  }
  /**
   * 查询对象
   */
  static searchDTO: ProjectApplicationSearchDTOType = {
    projectName: '',
    status: 0,
    page: {
      current: 1,
      size: 20,
    },
  }
  static searchVO: ProjectApplicationSearchVOType = {
    applyTime: '',
    createBy: '',
    createTime: '',
    id: 0,
    projectId: 0,
    projectName: '',
    reviewComment: '',
    reviewName: 0,
    reviewTime: '',
    reviewerId: 0,
    status: 0,
    studentId: 0,
    studentName: '',
    teacherName: '',
    updateBy: '',
    updateTime: '',
  }
}
